#include <aos/aos.h>
#include "aos/cli.h"
#include <stdio.h>
#include <pthread.h>

#define ANV_TRACE_IMPLEMENTATION
#include <anv_trace.h>

static void * anv_trace_thread(void *arg)
{
    anv_trace_init(stdout);

    anv_trace_enter();
    anv_traced("Hello %s!", "Debug");
    anv_tracei("Hello %s!", "Info");
    anv_tracew("Hello %s!", "Warning");
    anv_tracee("Hello %s!", "Error");
    anv_tracef("Hello %s!", "Fatal");
    anv_trace_leave();

    anv_trace_quit();

    return 0;  
}

int yoc_anv_trace_example(int argc, char *argv[])
{
    int ret = 0;
    int thread_para;
    pthread_t new_thread;
    pthread_attr_t attr;
    int *retval;

    thread_para = 10;
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr, 4096);
    ret = pthread_create(&new_thread, &attr, anv_trace_thread, &thread_para);
    if (ret != 0) {
        printf("pthread_create failed, ret:%d\n", ret);
        pthread_attr_destroy(&attr);
        return -1;
    }
    return 0;
}
ALIOS_CLI_CMD_REGISTER(yoc_anv_trace_example,yoc_anv_trace_example, anv trace example);
